package cn.com.swu.mianyangapp.ui.news;

import android.annotation.SuppressLint;
import android.content.Context;
import android.provider.CalendarContract;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import java.util.ArrayList;
import java.util.List;
import java.util.logging.Handler;

import cn.com.swu.mianyangapp.R;
import cn.com.swu.mianyangapp.ui.bean.NewsType;
import cn.com.swu.mianyangapp.ui.bean.Remark;

public class NewsRemarkAdapter extends RecyclerView.Adapter<NewsRemarkAdapter.NewsRemarkViewHolder> {
    private List<Remark> mRemarkList = new ArrayList<>();
    private LayoutInflater mLayoutInflater;
    private Context mContext;

    public NewsRemarkAdapter(Context context, List<Remark> remarkList){
        this.mContext = context;
        this.mRemarkList = remarkList;
        mLayoutInflater = LayoutInflater.from(mContext);


    }
    @NonNull
    @Override
    public NewsRemarkViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = mLayoutInflater.inflate(R.layout.fragment_news_remark_item,parent,false);
        NewsRemarkViewHolder newsRemarkViewHolder = new NewsRemarkViewHolder(view);
        return newsRemarkViewHolder;
    }

    @SuppressLint("SetTextI18n")
    @Override
    public void onBindViewHolder(@NonNull NewsRemarkAdapter.NewsRemarkViewHolder holder, int position) {
        Remark remark = mRemarkList.get(position);
        holder.mTextViewAuthor.setText(remark.getRemark_author() + ":");
        holder.mTextViewContext.setText(remark.getRemark_context());
        holder.mTextViewTime.setText(remark.getRemark_time());
    }

    @Override
    public int getItemCount() {
        return mRemarkList.size();
    }

    public class NewsRemarkViewHolder extends RecyclerView.ViewHolder {
        TextView mTextViewAuthor;

        TextView mTextViewContext;
        TextView mTextViewTime;
        public NewsRemarkViewHolder(@NonNull View itemView) {
            super(itemView);
            this.mTextViewAuthor = itemView.findViewById(R.id.news_remark_author);
            this.mTextViewContext = itemView.findViewById(R.id.news_remark_context);
            this.mTextViewTime = itemView.findViewById(R.id.news_remark_time);

        }
    }
}
